package it.cinema.mobile.biz;

import it.cinema.mobile.data.Film;
import it.cinema.mobile.data.Parameter;
import java.io.Serializable;
import java.util.List;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;

@ManagedBean
@ViewScoped
public class FilmController implements Serializable {
	private static final long serialVersionUID = 1L;
	private static final Logger log = Logger.getLogger(it.cinema.mobile.biz.FilmController.class.getName());

	@ManagedProperty(value="#{parameter}")
	private Parameter parameter;

	@ManagedProperty(value="#{filmDAO}")
	private transient FilmDAO filmDAO;
	
	private List<Film> films;
	private Film selectedFilm;
	
	public FilmController() {
	}
	
	@PostConstruct
	public void init(){
		log.info("Parametri : Cinema="+parameter.getCinema()+"&Films="+parameter.getFilms());
		films = filmDAO.findFilm(parameter);
	}

	public List<Film> getFilms() {
		return films;
	}

	public Film getSelectedFilm() {
		return selectedFilm;
	}

	public void setSelectedFilm(Film selectedFilm) {
		this.selectedFilm = selectedFilm;
	}
	
	public void setParameter(Parameter parameter){
		this.parameter = parameter;
	}

	public void setFilmDAO(FilmDAO filmDAO){
		this.filmDAO = filmDAO;
	}
}